package com.itheima.web;

import com.itheima.pojo.ShoppingCart;
import com.itheima.result.R;
import com.itheima.service.ShoppingCartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @Author: 斌
 * @DateTime: 2023年02月10日  21:13:31
 * @Description: com.itheima.web
 * @Version: 1.0
 */
@RestController
@RequestMapping("/shoppingCart")
public class ShoppingCartController {
    @Autowired
    private ShoppingCartService shoppingCartService;

    @GetMapping("/list")
    public R shopCartList(HttpSession session){
      return   shoppingCartService.shopCartList(session);
    }
    @PostMapping("/add")
    public R addCart(@RequestBody ShoppingCart shoppingCart,HttpSession session){
        return shoppingCartService.addCart(shoppingCart,session);
    }

    @PostMapping("/sub")
    public R removeCart(@RequestBody ShoppingCart shoppingCart,HttpSession  session){
       return shoppingCartService.removeCart(shoppingCart,session);
    }
    @DeleteMapping("/clean")
    public R deleteCart(){
        return shoppingCartService.deleteCart();
    }

}
